<?php
namespace app\index\controller;

use app\common\controller\Base;
use app\index\model\BattleReport;
use app\index\model\Item;
use app\index\model\Mail;
use app\index\model\Op;

/**
 * 玩家日志
 */
class Journal extends Base
{

    use \app\index\controller\traits\User;
    use \app\index\controller\traits\Skill;
    use \app\index\controller\traits\Monster;
    use \app\index\controller\traits\Resource;
    //自PHP5.4起
    private $menuArray = [

        "1"  => ["name" => "登录", "children" => ["10", "11"]],

        "10" => ["name" => 'Game.login', "cname" => "登录"],
        "11" => ["name" => 'Game.logout', "cname" => "下线"],

        "2"  => ["name" => "背包道具", "children" => ["20", "21", "22", "23"]],

        "20" => ["name" => 'Item.use_item', "cname" => "道具使用"],
        "21" => ["name" => 'Item.sell_item', "cname" => "道具出售"],
        "22" => ["name" => 'Item.mix_rune', "cname" => "符文合成"],
        "23" => ["name" => 'Heroes.forge_equipment', "cname" => "装备锻造"],

        "3"  => ["name" => "功能养成", "children" => ["30", "31", "32", "33"]],

        "30" => ["name" => "Monster.employ_monster", "cname" => "佣兵招募"],
        "31" => ["name" => "Monster.upgrade_monster", "cname" => "佣兵升星"],
        "32" => ["name" => "Heroes.unlock_skill", "cname" => "技能解锁"],
        "33" => ["name" => "Heroes.upgrade_skill", "cname" => "技能升级"],

        "4"  => ["name" => "副本", "children" => ["40", "41", "42"]],

        "40" => ["name" => "InstanceZones.start_battle", "cname" => "据点战斗"],
        "41" => ["name" => "InstanceZones.receive_treasure", "cname" => "拾取地图箱子"],
        "42" => ["name" => "InstanceZones.inbreak_leave_word", "cname" => "完成任务"],

        "5"  => ["name" => "入侵", "children" => ["50", "51"]],

        "50" => ["name" => "Battle.start_battle", "cname" => "据点战斗"],
        "51" => ["name" => "InstanceZones.receive_treasure", "cname" => "拾取宝藏"],

        //竞技场
        //"6" => ["60"],

        "7"  => ["name" => "商品购买", "children" => ["70"]],

        "70" => ["name" => "Shop.buy_store_goods", "cname" => "商城购买"],

        "8"  => ["name" => "占卜", "children" => ["80", "81"]],

        "80" => ["name" => "DrawCard.draw_card", "type" => 1, "cname" => "佣兵占卜"],
        "81" => ["name" => "DrawCard.draw_card", "type" => 2, "cname" => "技能占卜"],

        "9"  => ["name" => "奖励领取", "children" => ["91", "92", "93", "95", "96"]],

        "91" => ["name" => "Task.cmd_get_prize", "type" => 0, "cname" => "领取任务奖励"],
        "92" => ["name" => "Task.cmd_get_prize", "type" => 1, "cname" => "领取成就宝箱"],
        "93" => ["name" => "Task.cmd_get_prize", "type" => 2, "cname" => "领取活跃度宝箱"],
        "94" => ["name" => "Mail.pickup_prize", "cname" => "领取邮件/战报奖励"],
        "95" => ["name" => "Friend.pick_up_coin", "cname" => "接受好友金币"],
    ];

    /**
     * 表字段初始化
     */
    public function _initialize()
    {

        //utf-8
        header("Content-Type: text/html; charset=utf-8");

        $this->hero       = $this->getArrFromXml("./static/xml/acc_dragon_hero.xml");
        $this->prize      = $this->getPrizeFromXml("./static/xml/acc_dragon_prize.xml");
        $this->prop       = $this->getPropertyFromXml("./static/xml/acc_dragon_prop.xml");
        $this->monster    = $this->getMonsterArr("./static/xml/acc_dragon_monster.xml");
        $this->drawcard   = $this->getDrawCardFromXml("./static/xml/acc_dragon_drawcard.xml");
        $this->task_prize = $this->getTaskPrizeFromXml("./static/xml/acc_dragon_task_prize.xml");
        $this->goods      = $this->getGoodsArr("./static/xml/acc_dragon_prop.xml", "./static/xml/acc_dragon_goods.xml");
        $this->skillid    = $this->getSkillArr("./static/xml/acc_dragon_skill.xml", "./static/xml/acc_hero_skill.xml");

        //基类授权
        //
        parent::_initialize();
    }
    /**
     * 任务表转换
     * @DateTime 2018-01-13
     * @param    [type] $xml_file_prize [description]
     * @return   [type]
     */
    public function getTaskPrizeFromXml($xml_file_prize)
    {
        $xmlNode = simplexml_load_file($xml_file_prize);

        $temp = \app\ux\UtilXml::xmlToArray($xmlNode);
        $temp = $temp ? $temp["RECORDS"]["RECORD"] : $temp;

        if ($temp) {
            $rtn = array();
            foreach ($temp as $k => $v) {
                $rtn[$v['id']]['prizes'] = $v['prizeid'];
                $rtn[$v['id']]['desc']   = $v['desc'];
            }
        }
        return $rtn;
    }
    /**
     * 道具表
     * @DateTime 2018-01-13
     * @param    [type] $xml_file [description]
     * @return   [type]
     */
    public function getPropertyFromXml($xml_file)
    {
        $xmlNode = simplexml_load_file($xml_file);
        $temp    = \app\ux\UtilXml::xmlToArray($xmlNode);
        $temp    = $temp ? $temp["RECORDS"]["RECORD"] : $temp;
        if ($temp) {
            $rtn = array();
            foreach ($temp as $k => $v) {
                $rtn[$v['id']]['name']         = $v['name'];
                $rtn[$v['id']]['made_formula'] = $v['made_formula'];
                $rtn[$v['id']]['made_gold']    = $v['made_gold'];
            }
        }
        return $rtn;
    }
    /**
     * 奖励表转换
     * @DateTime 2018-01-13
     * @param    [type] $xml_file_prize [description]
     * @return   [type]
     */
    public function getPrizeFromXml($xml_file_prize)
    {

        $xmlNode = simplexml_load_file($xml_file_prize);

        $temp = \app\ux\UtilXml::xmlToArray($xmlNode);
        $temp = $temp ? $temp["RECORDS"]["RECORD"] : $temp;

        if ($temp) {
            $rtn = array();

            foreach ($temp as $k => $v) {
                $rtn[$v['id']]['prize'] = $v['prize'];
                $rtn[$v['id']]['desc']  = $v['desc'];
            }
        }
        return $rtn;
    }
    /**
     * 占卜表转换
     * @DateTime 2018-01-13
     * @param    [type] $xml_file [description]
     * @return   [type]
     */
    public function getDrawCardFromXml($xml_file)
    {

        $xmlNode = simplexml_load_file($xml_file);
        $temp    = \app\ux\UtilXml::xmlToArray($xmlNode);
        $temp    = $temp ? $temp["RECORDS"]["RECORD"] : $temp;
        if ($temp) {
            $rtn = array();
            foreach ($temp as $k => $v) {
                $rtn[$v['id']]['name']        = $v['name'];
                $rtn[$v['id']]['item_id']     = $v['item_id'];
                $rtn[$v['id']]['consumption'] = $v['consumption'];
                $rtn[$v['id']]['prize']       = $v['prize'];
            }
        }
        return $rtn;
    }
    /**
     * 商品表
     *
     * @param    [type] $xml_file_prop [description]
     * @param    [type] $xml_file_goods [description]
     * @return   [type]
     */
    public function getGoodsArr($xml_file_prop, $xml_file_goods)
    {

        $currency_type = ['1' => '金币', '2' => '钻石', '3' => '充值RMB'];

        $prop    = $this->getArrFromXml($xml_file_prop);
        $xmlNode = simplexml_load_file($xml_file_goods);

        $temp = \app\ux\UtilXml::xmlToArray($xmlNode);
        $temp = $temp ? $temp["RECORDS"]["RECORD"] : $temp;

        if ($temp) {
            $rtn = array();

            foreach ($temp as $k => $v) {

                //出售资源
                if (!empty($v['sell_resources'])) {
                    $rtn[$v['id']]['sell'] = $this->getResource($v['sell_resources']);
                } else {
                    $rtn[$v['id']]['sell'] = '';
                }
                //赠送资源
                if (!empty($v['gift_resources'])) {
                    if (!empty($rtn[$v['id']]['sell'])) {
                        $rtn[$v['id']]['sell'] .= ';' . $this->getResource($v['gift_resources']);
                    } else {
                        $rtn[$v['id']]['sell'] = $this->getResource($v['gift_resources']);
                    }
                }
                //出售道具
                if (!empty($v['item_id'])) {
                    if (!empty($rtn[$v['id']]['sell'])) {
                        if (array_key_exists($v['item_id'], $prop)) {
                            $rtn[$v['id']]['sell'] .= ';' . $prop[$v['item_id']];
                        } else {
                            $rtn[$v['id']]['sell'] .= ';' . $v['item_id'];
                        }
                    } else {
                        if (array_key_exists($v['item_id'], $prop)) {
                            $rtn[$v['id']]['sell'] = $prop[$v['item_id']];
                        } else {
                            $rtn[$v['id']]['sell'] = $v['item_id'];
                        }
                    }
                }
                //以上为获得商品,以下为消耗价值
                $rtn[$v['id']]['use'] = (array_key_exists($v['currency_type'], $currency_type) ? $currency_type[$v['currency_type']] : $v['currency_type']) . '*' . $v['price'];
            }
        }
        return $rtn;
    }
    /**
     * 基本信息查询
     */
    public function queryBasicInfo()
    {

        //角色ID和昵称
        $id       = array_key_exists("id", $_REQUEST) ? $_REQUEST['id'] : null;
        $nickname = array_key_exists("nickname", $_REQUEST) ? $_REQUEST['nickname'] : null;

        //角色ID查询
        $id = $this->getUserId($id, $nickname);

        if (empty($id)) {
            _callback(array('success' => true, 'msg' => "提示:没有找到玩家信息", 'type' => "user-not-exist"));
        }

        $operaId   = input('get.operation/s');
        $startdate = input('get.startdate/s');
        $enddate   = input('get.enddate/s');

        $operaMenu = $this->menuArray;

        //模型实例
        $model = new Op();

        if (array_key_exists($operaId, $operaMenu)) {

            $res = [];
            $map = [];
            /*
             * 菜单一级
             * 首先获取一级下子菜单的索引，然后根据子菜单项中的[ type类型 + method操作方法 + 玩家角色ID ]构造查询条件
             * 匹配acc_dragon_op表记录, 子菜单操作的查询结果合并到数组 $res 之后返回;
             */

            if (1 == strlen($operaId)) {

                $subMenu = $operaMenu[$operaId]['children'];

                $timestart = $startdate ? strtotime($startdate) : 0;
                $timeend   = $enddate ? (strtotime($enddate) + 86400) : 0;

                $map['create_time'] = array('between', array($timestart, $timeend));

                $typeName = $operaMenu[$operaId]['name'];

                foreach ($subMenu as $k => $v) {

                    $map['cid']    = $id;
                    $map['method'] = $operaMenu[$v]['name'];

                    //占卜和奖励类型判断
                    switch ($operaId) {
                        case '8':
                            $map['msg'] = array('like', '%"draw_type":' . $operaMenu[$v]['type'] . '%');
                            break;

                        case '9':
                            $map['msg'] = array('like', '%"type":' . $operaMenu[$v]['type'] . '%');
                            break;
                    }

                    $result = $model->where($map)
                        ->select();

                    //dump($model->getLastSql());

                    foreach ($result as $data) {

                        $temp          = $data->getData();
                        $temp['type']  = $typeName;
                        $temp['cname'] = $operaMenu[$v]['cname'];
                        array_push($res, $temp);
                    }
                }

                if ($res) {
                    $return['rows']    = $res;
                    $return['total']   = count($res);
                    $return['success'] = true;
                } else {
                    $return['rows']    = array();
                    $return['total']   = 0;
                    $return['success'] = true;
                }

                _callback($return);
                /*
             * 菜单二级
             * 根据子菜单项中的[ type类型 + method操作方法 + 玩家角色ID ]构造查询条件
             * 匹配acc_dragon_op表记录, 查询结果存储到数组 $res 之后返回;
             */

            } else if (2 == strlen($operaId)) {

                $map = [
                    'cid'    => $id,
                    'method' => $operaMenu[$operaId]['name'],
                ];

                $typeId   = substr($operaId, 0, 1);
                $typeName = $operaMenu[$typeId]['name'];

                //占卜奖励类型判断
                switch ($typeId) {
                    case '8':
                        $map['msg'] = array('like', '%"draw_type":' . $operaMenu[$operaId]['type'] . '%');
                        break;
                    case '9':
                        if ('91' == $operaId || '92' == $operaId || '93' == $operaId) {
                            $map['msg'] = array('like', '%"type":' . $operaMenu[$operaId]['type'] . '%');
                        }
                        break;
                }

                //执行查询,返回数据对象数组
                $result = $model->field($model->getField())
                    ->where($map)
                    ->select();

                //dump($model->getLastSql());

                //遍历数据对象数组
                foreach ($result as $data) {

                    $temp = $data->getData();

                    $temp['type']  = $typeName;
                    $temp['cname'] = $operaMenu[$operaId]['cname'];

                    //增加占卜和奖励类型判断
                    switch ($operaId) {
                        case '10': //用户下线
                        case '11': //用户登录
                            break;
                        case '20': //道具使用
                        case '21': //道具出售
                        case '22': //符文合成
                            $msg = $data['msg'];
                            $this->transferUseItem($temp, $msg);
                            break;
                        case '23': //装备锻造
                            $msg = $data['msg'];
                            $this->transferPropItem($temp, $msg);
                            break;
                        case '30': //佣兵招募
                            $msg              = $data['msg'];
                            $temp['comments'] = $this->transferMonsterId($msg);
                            break;
                        case '31': //佣兵升星
                            $msg              = $data['msg'];
                            $temp['comments'] = $this->transferMonsterId($msg);
                            break;
                        case '32': //技能解锁
                        case '33': //技能升级
                            $msg              = $data['msg'];
                            $temp['comments'] = $this->transferHeroId($msg);
                            break;
                        case '50': //据点战斗
                            break;
                        case '51': //拾取宝藏
                            break;
                        case '6':
                            break;
                        case '70': //商城购买
                            $msg = $data['msg'];
                            $this->transferGoodsId($temp, $msg);
                            break;
                        case '80': //佣兵占卜
                        case '81': //技能占卜
                            $msg = $data['msg'];
                            $this->transferDrawcard($temp, $msg);
                            break;
                        case '91': //完成任务
                        case '92': //成就点
                        case '93': //活跃度
                            $msg = $data['msg'];
                            $this->transferPrize($temp, $msg);
                            break;
                        case '94': //邮件战报
                            $msg = $data['msg'];
                            $this->transferMailPrize($temp, $msg);
                            break;
                        case '95': //接受好友金币
                            $temp['get']      = '[金币]*200'; //基础功能表好友赠送金币
                            $msg              = $data['msg'];
                            $temp['comments'] = $this->transferFriendCoin($msg);
                            break;
                        default:
                            break;
                    }
                    array_push($res, $temp);
                }

                if ($res) {
                    $return['rows']    = $res;
                    $return['total']   = count($res);
                    $return['success'] = true;
                } else {
                    $return['rows']    = array();
                    $return['total']   = 0;
                    $return['success'] = true;
                }

                _callback($return);
            }

        } else {
            _callback(array('success' => false, 'msg' => "提示:操作代码不匹配"));
        }
    }
    //itemid转换道具名称
    public function transferItemid($item_id)
    {
        $temp = Item::get($item_id);
        if ($temp) {
            $data  = $temp->getData();
            $cid   = $data['cid'];
            $props = $this->prop;
            return (array_key_exists($cid, $props) ? $props[$cid]['name'] : $cid);
        } else {
            return 'item_id_' . $item_id;}
    }

    //Item表
    public function transferUseItem(&$temp, $msg)
    {
        $_temp       = json_decode($msg, true);
        $name        = $this->transferItemid($_temp["item_id"]);
        $num         = $_temp["num"];
        $temp['use'] = ("[" . $name . "]*" . $num);
        $temp['get'] = '';
    }

    //道具表
    public function transferPropItem(&$temp, $msg)
    {

        $prop = $this->prop;

        $_temp  = json_decode($msg, true);
        $propid = $_temp['propid'];
        $props  = $this->prop;

        if (array_key_exists($propid, $props)) {
            $temp['get']  = $props[$propid]['name'];
            $made_gold    = $props[$propid]['made_gold'];
            $made_formula = $props[$propid]['made_formula'];

            $gold  = "金币*" . $made_gold;
            $items = $this->formulaToPropertyArr($made_formula);
            $res   = [];
            foreach ($items as $key => $item) {
                $item['id'] = array_key_exists($item['id'], $prop) ? $prop[$item['id']]['name'] : $item['id'];
                $res[$key]  = $item['id'] . '*' . $item['num'];
            }
            if (!empty($res)) {
                $temp['use'] = implode('；', $res);
                $temp['use'] .= '；' . $gold;
            } else {
                $temp['use'] = $gold;
            }
        } else {
            $temp['get']      = $propid;
            $temp['comments'] = "未找到匹配道具";
        }
    }
    /**
     * 公式转换表
     * @DateTime 2018-01-13
     * @param    [type] $msg [description]
     * @return   [type]
     */
    public function formulaToPropertyArr($msg)
    {
        $arr = explode(';', $msg);
        $res = [];
        foreach ($arr as $v) {
            $temp        = [];
            $item        = explode('=', $v);
            $temp['id']  = $item[0];
            $temp['num'] = $item[1];
            array_push($res, $temp);
        }
        return $res;
    }
    //佣兵
    public function transferMonsterId($msg)
    {

        $monster = $this->monster;
        $temp    = json_decode($msg, true);

        $monsterid = array_key_exists("monsterid", $temp) ? $temp['monsterid'] : null;
        $num       = array_key_exists("count", $temp) ? $temp['count'] : null;

        if (array_key_exists($monsterid, $monster)) {
            $m = $monster[$monsterid];
            if ($num) {
                return ($m['name'] . '*' . $num);
            } else {
                return $m['name'];}
        } else {
            return ('[monsterid]:' . $monsterid);
        }
    }

    //领主技能解锁升级
    public function transferHeroId($msg)
    {

        $_hero  = $this->hero;
        $_skill = $this->skillid;

        $temp    = json_decode($msg, true);
        $heroid  = array_key_exists("heroid", $temp) ? $temp['heroid'] : null;
        $skillid = array_key_exists("skillid", $temp) ? $temp['skillid'] : null;

        if (array_key_exists($heroid, $_hero)) {

            if (array_key_exists($skillid, $_skill)) {
                $data = $_skill[$skillid];
                $rtn  = $_hero[$heroid] . ' 解锁技能 ' . $data["skill_name"][0];
                return $rtn;
            } else {
                return $_hero[$heroid];}
        } else {
            return '[heroid]:' . $heroid;
        }
    }

    //商城购买
    public function transferGoodsId(&$temp, $msg)
    {

        $_goods = $this->goods;

        $_temp = json_decode($msg, true);

        $goods_id = array_key_exists("goods_id", $_temp) ? $_temp['goods_id'] : null;
        $count    = array_key_exists("goods_count", $_temp) ? $_temp['goods_count'] : null;

        if (array_key_exists($goods_id, $_goods)) {
            $temp['get'] = '[' . ($_goods[$goods_id]['sell'] . ']*' . $count);
            $temp['use'] = $_goods[$goods_id]['use'];
        } else {
            $temp['get'] = '[goodsid]:' . $goods_id . '*' . $count;
        }

    }
    //抽卡信息
    public function transferDrawcard(&$temp, $msg)
    {

        $props    = $this->prop;
        $drawcard = $this->drawcard;

        $_temp = json_decode($msg, true);

        $res = ['1' => '道具',
            '2'         => '钻石'];
        if (array_key_exists('cost_type', $_temp)) {

            $_type       = $_temp['cost_type'];
            $temp['get'] = array_key_exists($_type, $drawcard) ? $this->getResourceName($drawcard[$_type]['prize']) : '';

            if (array_key_exists($_type, $drawcard)) {

                $arr = explode('=', $drawcard[$_type]['consumption']);

                switch ($_type) {
                    case 1:
                        $temp['use'] = array_key_exists($drawcard[$_type]['item_id'], $props) ? $props[$drawcard[$_type]['item_id']] : $drawcard[$_type]['item_id'];
                        break;
                    case 2:
                        $temp['use'] = $this->getResourceName($arr[0]) . '*' . $arr[1];
                        break;
                }

            } else {
                $temp['use'] = '';
            }

            $temp['comments'] = "消耗类型:" . $res[$_type];
        }
    }
    //领取活跃度/成就/任务奖励
    public function transferPrize(&$temp, $msg)
    {

        $prize      = $this->prize;
        $props      = $this->prop;
        $task_prize = $this->task_prize;

        $res = ['0' => '领取任务奖励',
            '1'         => '领取成就宝箱',
            '2'         => '领取日活跃度宝箱',
            '3'         => '领取周活跃度宝箱'];

        $_temp = json_decode($msg, true);

        if (array_key_exists('type', $_temp)) {
            $_type         = $_temp['type'];
            $temp['cname'] = $res[$_type];
        }

        $_id = $_temp['id'];
        $res = [];
        if (array_key_exists($_id, $prize)) {

            $_prize_array = explode(";", $prize[$_id]['prize']);

            foreach ($_prize_array as $v) {

                $_item     = explode("=", $v);
                $_item_id  = $_item[0];
                $_item_num = $_item[1];

                if (array_key_exists($_item_id, $props)) {
                    $_item = $props[$_item_id];
                    array_push($res, $_item . '*' . $_item_num);
                } else {
                    array_push($res, $this->getResourceName($_item_id) . '*' . $_item_num);
                }
            }
            //获得字段
            $temp['get']      = implode(';', $res);
            $temp['comments'] = $prize[$_id]['desc'];

        } else if (array_key_exists($_id, $task_prize)) {

            $_task_prize      = $task_prize[$_id]['prizes'];
            $temp['comments'] = $task_prize[$_id]['desc'];

            $_prize_array = explode(";", $_task_prize);

            foreach ($_prize_array as $v) {

                $_item      = explode("=", $v);
                $_item_name = $this->getResourceName($_item[0]);
                $_item_num  = $_item[1];

                array_push($res, $_item_name . '*' . $_item_num);
            }
            //获得字段
            $temp['get'] = implode(';', $res);
        }
    }
    //领取邮件奖励
    public function transferMailPrize(&$temp, $msg)
    {

        $props = $this->prop;

        $_temp = json_decode($msg, true);
        $sid   = array_key_exists("sid", $_temp) ? $_temp['sid'] : null;

        if (!empty($sid)) {
            $record = Mail::get($sid);

            if ($record) {

                $data = $record->getData();

                if (!empty($data['mail_id'])) {

                    $temp['cname']    = "领取邮件奖励";
                    $temp['comments'] = $data['title'] . ':' . $data['content'];

                    $prizes      = $this->getPrizeContent($props, $data['prize_ids'], $data['prize_counts']);
                    $temp['get'] = implode(";", $prizes);

                } else if (!empty($data['report_sid'])) {

                    $temp['cname'] = "领取战报奖励";
                    $report_prize  = BattleReport::get($record['report_sid']);

                    if (!empty($report_prize)) {

                        $prize_data  = $report_prize->getData();
                        $prizes      = $this->getPrizeContent($props, $prize_data['prize_ids'], $prize_data['prize_counts']);
                        $temp['get'] = implode(";", $prizes);
                    }
                }
            } else {
                $temp['comments'] = "未查到奖励记录";
            }
        }
    }
    //好友赠送接受金币信息
    public function transferFriendCoin($msg)
    {
        $temp      = json_decode($msg, true);
        $friend_id = array_key_exists("friend_id", $temp) ? $temp['friend_id'] : null;
        return "好友ID:" . $friend_id;
    }
    /**
     * 分页
     */
    public function pagination()
    {
        $this->page   = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; #是否预先设置了页码,如有没有则当前默认页码为1
        $this->rows   = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 25; #是否预先设置了单页面行数,如没有则按照每页行数为10
        $this->offset = isset($_REQUEST['start']) ? intval($_REQUEST['start']) : ($this->page - 1) * $this->rows; #根据当前页码或请求参数设置偏移量
        $this->limit  = "'" . $this->offset . ',' . $this->rows . "'";
    }

    /**
     * 战报邮件奖励字段内容转换
     * @DateTime 2018-01-13
     * @param    [type] &$props [description]
     * @param    [type] $prize_ids [description]
     * @param    [type] $prize_counts [description]
     * @return   [type]
     */
    public function getPrizeContent(&$props, $prize_ids, $prize_counts)
    {

        $prizes = \app\ux\UtilArr::noEmpty((!empty($prize_ids)) ? explode(";", $prize_ids) : []);
        $counts = \app\ux\UtilArr::noEmpty((!empty($prize_counts)) ? explode(";", $prize_counts) : []);

        $prizes_num = count($prizes);
        $counts_num = count($counts);

        $res = [];
        if ((0 != $prizes_num) && (0 != $counts_num) && ($prizes_num == $counts_num)) {

            for ($i = 0; $i < $prizes_num; $i++) {

                if (array_key_exists($prizes[$i], $props)) {
                    $prize_name = $props[$prizes[$i]];
                } else {
                    $prize_name = $this->getResourceName($prizes[$i]);
                }

                $prize_num = $counts[$i];
                array_push($res, '[' . $prize_name . ']*' . $prize_num);
            }
        }
        return ($res);
    }
}
